<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="949.27">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #a82827}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
span.s1 {font: 18.0px Helvetica}
span.s2 {color: #0030f5}
span.s3 {color: #0043ec}
span.s4 {color: #003ca9}
span.s5 {color: #606060}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1"><span class="s1"><b>Coyote<span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span><span class="Apple-tab-span">	</span></b></span><b>an amplitude tracking based onset detector</b></p>
<p class="p2"><br></p>
<p class="p1"><b>Coyote.kr(in, trackFall, slowLag, fastLag, fastMul, thresh, minDur)</b></p>
<p class="p2"><br></p>
<p class="p1">Coyote is an onset detector which tries to find onset attacks in a signal without using FFT processing. It tracks the amplitude changes in the incoming signal and sends a trigger when an onset is found. To get the best tracking for a particular signal by tweaking the arguments, one needs to understand how the onset detection works inside the UGen:</p>
<p class="p2"><br></p>
<p class="p1">Coyote compares three different analysis results in parallel and tries to report an onset event in the signal. The first phase is amplitude tracking. The trackFall argument is the 60dB convergence time of the decaying signal(the attack time is constant: 0.001, the process is the same with the <a href="Analysis/Amplitude.html"><span class="s2">Amplitude</span></a> UGen, trackFall is the releaseTime). The output of this tracking is divided to 3 inputs inside. The first two are smoothers(lowpass filters) with different lag times. slowLag is the lag time of the slow smoother, and the fastLag is the lag time of the fast one. The fast smoother is multiplied by a value(fastMul argument) which should be between 0 and 0.9 so its output is always below the slow smoother, except in onsets. So when an onset occurs, the fast smoother output rises quicker than the slow smoother, and when the fast one exceeds the slower at an instant(occurs only at onsets), a trigger is sent to the output from the UGen. For the next trigger to happen, a specified time should pass which is defined by the minDur parameter. So minDur defines the minimum time between events/triggers.</p>
<p class="p2"><br></p>
<p class="p1">This approach is extremely fast in response(compared to FFT based detectors) when detecting onsets and works well on most contexts(guitar, percussion, etc...). But it has a drawback when there are sustaining sounds present from the same instrument at the moment of an onset, so there is a third unit inside that averages the input beginning from the last trigger whose output is also smoothed by a smoother(lag time is also set to slowLag) and it too is compared with the output of fast smoother to make the tracking work better when there are sustaining sounds present at the moment of an onset.</p>
<p class="p2"><br></p>
<p class="p1">The default values are a good starting point and works well on many contexts.</p>
<p class="p2"><br></p>
<p class="p1"><b>in</b> - Signal input.</p>
<p class="p1"><b>trackFall</b> - 60dB convergence time for the initial amplitude tracker.</p>
<p class="p1"><b>slowLag</b> - Lag time for the slow smoother. (Default 0.2)</p>
<p class="p1"><b>fastLag</b> - Lag time for the fast smoother. (Default: 0.01)</p>
<p class="p1"><b>fastMul</b> - Multiplier for the fast smoother. At the instant of onsets, fast smoother output will exceed the slow smoother and trigger an onset report. If you want to tweak the sensitivity of the tracking, you should try tweaking this value first. Higher values(approaching to 1) makes the tracking more sensitive. (Default: 0.5)</p>
<p class="p1"><b>thresh</b> - The minimum threshold for the input to begin tracking onsets. (Default: 0.05)</p>
<p class="p1"><b>minDur</b> - Minimum duration between events. (Default: 0.1)</p>
<p class="p2"><br></p>
<p class="p1"><b>See also:</b> <a href="MachineListening/Onsets.html"><span class="s3">Onsets</span></a></p>
<p class="p2"><br></p>
<p class="p3">// Right speaker is the source and at left is a burst of noise when an onset is detected</p>
<p class="p4">(</p>
<p class="p4"><span class="s4">SynthDef</span>(<span class="s5">"coyote"</span>, {<span class="Apple-converted-space">  </span><span class="s4">var</span> sounds = <span class="s4">Mix</span>.fill(3, { <span class="s4">var</span> trig = <span class="s4">Dust</span>.kr(1);</p>
<p class="p4"><span class="Apple-converted-space">                                                 </span><span class="s4">Saw</span>.ar(<span class="s4">TRand</span>.kr(50, 880, trig),<span class="Apple-converted-space"> </span></p>
<p class="p4"><span class="Apple-converted-space">                                                        </span><span class="s4">Decay</span>.kr(trig,<span class="Apple-converted-space"> </span></p>
<p class="p4"><span class="Apple-converted-space">                                                                 </span><span class="s4">TRand</span>.kr(0.1, 2, trig),<span class="Apple-converted-space"> </span></p>
<p class="p4"><span class="Apple-converted-space">                                                                 </span>3.reciprocal)); } );</p>
<p class="p5"><span class="Apple-converted-space">                      </span></p>
<p class="p4"><span class="Apple-converted-space">                      </span><span class="s4">var</span> detect = <span class="s4">PinkNoise</span>.ar(<span class="s4">Decay</span>.kr(<span class="s4">Coyote</span>.kr(sounds,<span class="Apple-converted-space"> </span></p>
<p class="p4"><span class="Apple-converted-space">                                                                   </span>fastMul: 0.6,<span class="Apple-converted-space"> </span></p>
<p class="p4"><span class="Apple-converted-space">                                                                   </span>thresh: 0.001), 0.2));</p>
<p class="p5"><span class="Apple-converted-space">                      </span></p>
<p class="p4"><span class="Apple-converted-space">                      </span><span class="s4">Out</span>.ar(0, [detect, sounds]); } ).send(s);</p>
<p class="p4">)</p>
<p class="p5"><br></p>
<p class="p4">x = <span class="s4">Synth</span>.new(<span class="s5">"coyote"</span>)</p>
<p class="p4">x.free;</p>
</body>
</html>
